It's less screwing around with GPtrArray in most cases.
-Subproject commit 0734be8c1211ba04ecdd14ff30b6c07dbf3b9a84
+Subproject commit b11ad335f459e3c61b317308da57de441660efd0
#include <string.h>
-gboolean
-ot_spawn_sync_checked (const char *cwd,
- char **argv,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean ret = FALSE;
- gs_unref_object GSSubprocessContext *context = NULL;
- gs_unref_object GSSubprocess *proc = NULL;
-
- context = gs_subprocess_context_new (argv);
- if (cwd)
- gs_subprocess_context_set_cwd (context, cwd);
-
- if ((proc = gs_subprocess_new (context, cancellable, error)) == NULL)
- goto out;
-
- if (!gs_subprocess_wait_sync_check (proc, cancellable, error))
- goto out;
-
- ret = TRUE;
- out:
- return ret;
-}
-
/**
* ot_thread_pool_new_nproc:
*
G_BEGIN_DECLS
-gboolean ot_spawn_sync_checked (const char *cwd,
- char **argv,
- GCancellable *cancellable,
- GError **error);
-
GThreadPool * ot_thread_pool_new_nproc (GFunc func,
gpointer user_data);
GError **error)
{
gboolean ret = FALSE;
- ot_lptrarray GPtrArray *args = NULL;
-
- args = g_ptr_array_new ();
- ot_ptrarray_add_many (args, "ostree", "admin",
- "--ostree-dir", gs_file_get_path_cached (self->ostree_dir),
- "update-kernel",
- gs_file_get_path_cached (deploy_path), NULL);
- if (opt_no_kernel)
- g_ptr_array_add (args, "--modules-only");
- g_ptr_array_add (args, NULL);
-
- if (!ot_spawn_sync_checked (gs_file_get_path_cached (self->ostree_dir),
- (char**)args->pdata, cancellable, error))
+
+ if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (self->ostree_dir),
+ GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+ cancellable, error,
+ "ostree", "admin",
+ "--ostree-dir", gs_file_get_path_cached (self->ostree_dir),
+ "update-kernel",
+ gs_file_get_path_cached (deploy_path),
+ opt_no_kernel ? "--modules-only" : NULL,
+ NULL))
goto out;
ret = TRUE;
if (!opt_no_repo_prune)
{
- ot_lptrarray GPtrArray *prune_argv = NULL;
ot_lfree char *repo_arg = NULL;
repo_arg = g_strconcat ("--repo=", gs_file_get_path_cached (repo_path), NULL);
-
- prune_argv = g_ptr_array_new ();
- ot_ptrarray_add_many (prune_argv, "ostree", repo_arg, "prune", "--refs-only", "--depth=0", NULL);
- g_ptr_array_add (prune_argv, NULL);
- if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
- (char**)prune_argv->pdata,
- cancellable, error))
+ if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
+ GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+ cancellable, error,
+ "ostree", repo_arg, "prune", "--refs-only",
+ "--depth=0", NULL))
goto out;
}
remote_name = remote_name_from_path (ostree_repo_get_config (repo),
deploy_name);
- subproc_args = g_ptr_array_new ();
{
ot_lfree char *repo_arg = g_strconcat ("--repo=",
gs_file_get_path_cached (repo_path),
NULL);
- ot_ptrarray_add_many (subproc_args, "ostree", "pull", repo_arg, remote_name, NULL);
- g_ptr_array_add (subproc_args, NULL);
- if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
- (char**)subproc_args->pdata,
- cancellable, error))
+ if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
+ GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+ cancellable, error,
+ "ostree", "pull", repo_arg, remote_name, NULL))
goto out;
-
- g_clear_pointer (&subproc_args, (GDestroyNotify)g_ptr_array_unref);
}
- subproc_args = g_ptr_array_new ();
{
ot_lfree char *opt_ostree_dir_arg = g_strconcat ("--ostree-dir=",
gs_file_get_path_cached (ostree_dir),
NULL);
- ot_ptrarray_add_many (subproc_args, "ostree", "admin", opt_ostree_dir_arg, "deploy",
- deploy_name, NULL);
- g_ptr_array_add (subproc_args, NULL);
-
- if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
- (char**)subproc_args->pdata,
- cancellable, error))
+ if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
+ GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+ cancellable, error,
+ "ostree", "admin", opt_ostree_dir_arg, "deploy",
+ deploy_name, NULL))
goto out;
}
initramfs_file = ot_gfile_from_build_path ("/boot", initramfs_name, NULL);
if (!g_file_query_exists (initramfs_file, NULL))
{
- ot_lptrarray GPtrArray *mkinitramfs_args = NULL;
ot_lobj GFile *tmpdir = NULL;
ot_lfree char *initramfs_tmp_path = NULL;
ot_lobj GFile *ostree_vardir = NULL;
if (!g_output_stream_close (tmp_log_out, cancellable, error))
goto out;
- mkinitramfs_args = g_ptr_array_new ();
/* Note: the hardcoded /tmp path below is not actually a
* security flaw, because we've bind-mounted dracut's view
* of /tmp to the securely-created tmpdir above.
*/
- ot_ptrarray_add_many (mkinitramfs_args,
- "linux-user-chroot",
- "--mount-readonly", "/",
- "--mount-proc", "/proc",
- "--mount-bind", "/dev", "/dev",
- "--mount-bind", gs_file_get_path_cached (ostree_vardir), "/var",
- "--mount-bind", gs_file_get_path_cached (tmpdir), "/tmp",
- "--mount-bind", gs_file_get_path_cached (ostree_moduledir), "/lib/modules",
- deploy_path,
- "dracut", "-f", "/tmp/initramfs-ostree.img", release,
- NULL);
- g_ptr_array_add (mkinitramfs_args, NULL);
-
g_print ("Generating initramfs using %s...\n", deploy_path);
- if (!ot_spawn_sync_checked (NULL, (char**)mkinitramfs_args->pdata,
- cancellable, error))
+ if (!gs_subprocess_simple_run_sync (NULL, GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+ cancellable, error,
+ "linux-user-chroot",
+ "--mount-readonly", "/",
+ "--mount-proc", "/proc",
+ "--mount-bind", "/dev", "/dev",
+ "--mount-bind", gs_file_get_path_cached (ostree_vardir), "/var",
+ "--mount-bind", gs_file_get_path_cached (tmpdir), "/tmp",
+ "--mount-bind", gs_file_get_path_cached (ostree_moduledir), "/lib/modules",
+ deploy_path,
+ "dracut", "-f", "/tmp/initramfs-ostree.img", release,
+
+ NULL))
goto out;
initramfs_tmp_file = g_file_get_child (tmpdir, "initramfs-ostree.img");
if (!have_grub_entry)
{
- ot_lptrarray GPtrArray *grubby_args = NULL;
ot_lfree char *add_kernel_arg = NULL;
ot_lfree char *initramfs_arg = NULL;
ot_lobj GFile *kernel_path = NULL;
goto out;
}
- grubby_args = g_ptr_array_new ();
add_kernel_arg = g_strconcat ("--add-kernel=", gs_file_get_path_cached (kernel_path), NULL);
initramfs_arg = g_strconcat ("--initrd=", "/boot/initramfs-ostree-", release, ".img", NULL);
- ot_ptrarray_add_many (grubby_args, "grubby", "--grub", add_kernel_arg, initramfs_arg,
- "--copy-default", "--title=OSTree", NULL);
- g_ptr_array_add (grubby_args, NULL);
-
g_print ("Adding OSTree grub entry...\n");
- if (!ot_spawn_sync_checked (NULL, (char**)grubby_args->pdata,
- cancellable, error))
+ if (!gs_subprocess_simple_run_sync (NULL, GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+ cancellable, error,
+ "grubby", "--grub", add_kernel_arg, initramfs_arg,
+ "--copy-default", "--title=OSTree", NULL))
goto out;
}
else
{
ot_lfree char *opt_repo_arg = g_strdup_printf ("--repo=%s/repo",
gs_file_get_path_cached (ostree_dir));
- const char *child_argv[] = { "ostree", opt_repo_arg, "init", NULL };
- if (!ot_spawn_sync_checked (NULL, (char**)child_argv, cancellable, error))
+ if (!gs_subprocess_simple_run_sync (NULL, GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+ cancellable, error,
+ "ostree", opt_repo_arg, "init", NULL))
{
g_prefix_error (error, "Failed to initialize repository: ");
goto out;